//
//  MyTenderJPCell.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2022/2/25.
//  Copyright © 2025 aowang. All rights reserved.
//

import UIKit

import Kingfisher
class MyTenderJPCell: TenderBaseCell {
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        
        self.contentView.addSubview(operateBtn)

        
    }
    lazy  var operateBtn:OperateBtnGroup = {
        let v = OperateBtnGroup(frame: CGRect.zero,btnAlignment:.right,cRadius_group: 3, titles: [],bWidth_group: 80)
        return v
    }()
    func makeConstrainsts() {
        
        dingwei.isHidden = true
        
        imageV.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView).offset(12)
            make.centerY.equalTo(self.contentView)
            make.width.height.equalTo(95)
        }
        lab1.snp.makeConstraints { (make) in
            make.left.equalTo(imageV.snp.right).offset(12)
            make.right.equalTo(self.contentView).offset(-10)
            make.top.equalTo(self.contentView).offset(12)
            //                make.bottom.equalTo(self).offset(-100)
        }
        btn1.snp.makeConstraints { (make) in
            make.left.equalTo(lab1)
            make.width.equalTo(60)
            make.height.equalTo(25)
            make.top.equalTo(lab1.snp.bottom).offset(3)
        }
        chujiaLab.snp.makeConstraints { (make) in
            make.centerY.equalTo(btn1)
            make.right.equalTo(self.contentView).offset(-10)
        }
        
        lab2.snp.makeConstraints { (make) in
            make.left.right.equalTo(lab1)
            make.top.equalTo(btn1.snp.bottom).offset(3)
        }
        lab3.snp.makeConstraints { (make) in
            make.left.right.equalTo(lab1)
            make.top.equalTo(lab2.snp.bottom).offset(3)
        }
        
        lab4.snp.makeConstraints { (make) in
            make.left.right.equalTo(lab1)
            make.top.equalTo(lab3.snp.bottom).offset(3)
            
        }
        
        
        oper_btn.isHidden = true
        
        
         operateBtn.snp.makeConstraints({ (make) in
             make.top.equalTo(lab4.snp.bottom).offset(2)
             make.left.equalTo(self.contentView).offset(10)
            make.right.equalTo(self.contentView).offset(-10)
            make.height.equalTo(28)
             make.bottom.equalTo(self.contentView).offset(-5)

        })
        
     
        
        
        
    }
    
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var one = ZtbContentModel(JSON:["":""])! {
        didSet {
            let col = #colorLiteral(red: 0, green: 0.4378578663, blue: 0.8206996322, alpha: 1)
            lab1.text = one.zTitle
            let real_status = one.zStatus.isSome ? intTran(one.zStatus) : intTran(one.zZbStatus)
            var btnName =  ""
             if real_status == 1 {
                btnName =  "已成交"
                 operateBtn.setTitle(["查看竞拍","车辆信息"],colors:[col,col])
            } else if real_status == 0 {
                btnName =  "未成交"
                operateBtn.setTitle(["查看竞拍"],colors:[col,col])
            } else {
                btnName =  "已弃拍"
                operateBtn.setTitle(["查看竞拍"],colors:[col,col])
            }
            btn1.setTitle(btnName, for: .normal)
            
 
            let ssst = btnName == "未开始" ? "\(one.zBeginDate.unwrap)开始" : "\(one.zEndDate.unwrap)结束"
            lab2.text =  "\(ssst)   \(one.zCity.unwrap)"
            lab3.text = "出栏时间:\(one.zDate.unwrap)至\(one.zDateEnd.unwrap)"
            lab4.text = one.zPriceRank.unwrap
            chujiaLab.text = "\(intTran(one.zBidCount))次出价"
            
            if  let imageUrl = URL(string:configKSURL(one)) {
                let resource = KF.ImageResource(downloadURL: imageUrl)
                imageV.kf.setImage(with: resource, placeholder: UIImage(named:"defaultImg"))
            }
          
            
            
            
//            oper_btn.setTitle("查看销售招标", for: .normal)
//            oper_btn.addTarget(self, action: #selector(btn2Action(sender:)), for: .touchUpInside)
            
            
            
            
            
        }
    }
    @objc func btn2Action(sender:UIButton) {
        if let closure = btn2Closure {
            closure(sender,sender.titleLabel!.text.unwrap)
        }
    }
    
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
